#include "gtkcsstypesprivate.h"
#include "gtkprivatetypebuiltins.h"
#include "gtkstylepropertiesprivate.h"
+#include "gtksymboliccolorprivate.h"
#include "gtktypebuiltins.h"
/* this is in case round() is not provided by the compiler,
{
if (_gtk_css_parser_try (parser, "currentcolor", TRUE))
{
- g_value_init (&values[i], GTK_TYPE_CSS_SPECIAL_VALUE);
- g_value_set_enum (&values[i], GTK_CSS_CURRENT_COLOR);
+ symbolic = gtk_symbolic_color_ref (_gtk_symbolic_color_get_current_color ());
}
else
{
symbolic = _gtk_css_parser_read_symbolic_color (parser);
if (symbolic == NULL)
return FALSE;
-
- g_value_init (&values[i], GTK_TYPE_SYMBOLIC_COLOR);
- g_value_set_boxed (&values[i], symbolic);
}
+ g_value_init (&values[i], GTK_TYPE_SYMBOLIC_COLOR);
+ g_value_set_boxed (&values[i], symbolic);
+
if (value_is_done_parsing (parser))
break;
}
#include "gtkprivatetypebuiltins.h"
#include "gtkshadowprivate.h"
#include "gtkstylecontextprivate.h"
+#include "gtksymboliccolorprivate.h"
#include "gtkthemingengine.h"
#include "gtktypebuiltins.h"
#include "gtkwin32themeprivate.h"
if (_gtk_css_parser_try (parser, "currentcolor", TRUE))
{
- g_value_unset (value);
- g_value_init (value, GTK_TYPE_CSS_SPECIAL_VALUE);
- g_value_set_enum (value, GTK_CSS_CURRENT_COLOR);
- return TRUE;
+ symbolic = gtk_symbolic_color_ref (_gtk_symbolic_color_get_current_color ());
+ }
+ else
+ {
+ symbolic = _gtk_css_parser_read_symbolic_color (parser);
+ if (symbolic == NULL)
+ return FALSE;
}
-
- symbolic = _gtk_css_parser_read_symbolic_color (parser);
- if (symbolic == NULL)
- return FALSE;
if (gtk_symbolic_color_resolve (symbolic, NULL, &rgba))
{
if (G_VALUE_HOLDS (specified, GTK_TYPE_CSS_SPECIAL_VALUE))
{
- g_assert (g_value_get_enum (specified) == GTK_CSS_CURRENT_COLOR);
- g_value_copy (_gtk_style_context_peek_property (context, "color"), computed);
}
else if (G_VALUE_HOLDS (specified, GTK_TYPE_SYMBOLIC_COLOR))
{
- if (_gtk_style_context_resolve_color (context,
- g_value_get_boxed (specified),
- &rgba))
+ GtkSymbolicColor *symbolic = g_value_get_boxed (specified);
+
+ if (symbolic == _gtk_symbolic_color_get_current_color ())
+ g_value_copy (_gtk_style_context_peek_property (context, "color"), computed);
+ else if (_gtk_style_context_resolve_color (context,
+ symbolic,
+ &rgba))
g_value_set_boxed (computed, &rgba);
else
g_value_set_boxed (computed, &white);
#include "gtkcssimageprivate.h"
#include "gtkgradient.h"
#include "gtkshadowprivate.h"
+#include "gtksymboliccolorprivate.h"
#include "gtkthemingengine.h"
#include "gtktypebuiltins.h"
#include "gtkwin32themeprivate.h"
/* for when resolvage fails */
restart:
- if (G_VALUE_HOLDS (specified, GTK_TYPE_CSS_SPECIAL_VALUE))
+ if (G_VALUE_HOLDS (specified, GTK_TYPE_SYMBOLIC_COLOR))
{
- g_assert (g_value_get_enum (specified) == GTK_CSS_CURRENT_COLOR);
+ GtkSymbolicColor *symbolic = g_value_get_boxed (specified);
+ GdkRGBA rgba;
- /* The computed value of the ‘currentColor’ keyword is the computed
- * value of the ‘color’ property. If the ‘currentColor’ keyword is
- * set on the ‘color’ property itself, it is treated as ‘color: inherit’.
- */
- if (g_str_equal (_gtk_style_property_get_name (GTK_STYLE_PROPERTY (property)), "color"))
+ if (symbolic == _gtk_symbolic_color_get_current_color ())
{
- GtkStyleContext *parent = gtk_style_context_get_parent (context);
-
- if (parent)
- g_value_copy (_gtk_style_context_peek_property (parent, "color"), computed);
+ /* The computed value of the ‘currentColor’ keyword is the computed
+ * value of the ‘color’ property. If the ‘currentColor’ keyword is
+ * set on the ‘color’ property itself, it is treated as ‘color: inherit’.
+ */
+ if (g_str_equal (_gtk_style_property_get_name (GTK_STYLE_PROPERTY (property)), "color"))
+ {
+ GtkStyleContext *parent = gtk_style_context_get_parent (context);
+
+ if (parent)
+ g_value_copy (_gtk_style_context_peek_property (parent, "color"), computed);
+ else
+ _gtk_css_style_compute_value (computed,
+ context,
+ _gtk_css_style_property_get_initial_value (property));
+ }
else
- _gtk_css_style_compute_value (computed,
- context,
- _gtk_css_style_property_get_initial_value (property));
+ {
+ g_value_copy (_gtk_style_context_peek_property (context, "color"), computed);
+ }
}
- else
+ else if (_gtk_style_context_resolve_color (context,
+ symbolic,
+ &rgba))
{
- g_value_copy (_gtk_style_context_peek_property (context, "color"), computed);
+ g_value_set_boxed (computed, &rgba);
}
- }
- else if (G_VALUE_HOLDS (specified, GTK_TYPE_SYMBOLIC_COLOR))
- {
- GdkRGBA rgba;
-
- if (!_gtk_style_context_resolve_color (context,
- g_value_get_boxed (specified),
- &rgba))
+ else
{
specified = _gtk_css_style_property_get_initial_value (property);
goto restart;
}
- g_value_set_boxed (computed, &rgba);
}
else
g_value_copy (specified, computed);
NULL,
GTK_CSS_AREA_PADDING_BOX);
- g_value_init (&value, GTK_TYPE_CSS_SPECIAL_VALUE);
- g_value_set_enum (&value, GTK_CSS_CURRENT_COLOR);
+ g_value_init (&value, GTK_TYPE_SYMBOLIC_COLOR);
+ g_value_set_boxed (&value, _gtk_symbolic_color_get_current_color ());
_gtk_style_property_register ("border-top-color",
GDK_TYPE_RGBA,
0,
typedef enum {
GTK_CSS_INHERIT,
- GTK_CSS_INITIAL,
- GTK_CSS_CURRENT_COLOR /*< nick=currentColor >*/
+ GTK_CSS_INITIAL
} GtkCssSpecialValue;
/* We encode horizontal and vertical repeat in one enum value.
COLOR_TYPE_SHADE,
COLOR_TYPE_ALPHA,
COLOR_TYPE_MIX,
- COLOR_TYPE_WIN32
+ COLOR_TYPE_WIN32,
+ COLOR_TYPE_CURRENT_COLOR
} ColorType;
struct _GtkSymbolicColor
return symbolic_color;
}
+/**
+ * _gtk_symbolic_color_get_current_color:
+ *
+ * Gets the color representing the CSS 'currentColor' keyword.
+ * This color will resolve to the color set for the color property.
+ *
+ * Returns: (transfer none): The singleton representing the
+ * 'currentColor' keyword
+ **/
+GtkSymbolicColor *
+_gtk_symbolic_color_get_current_color (void)
+{
+ static GtkSymbolicColor *current_color = NULL;
+
+ if (G_UNLIKELY (current_color == NULL))
+ {
+ current_color = g_slice_new0 (GtkSymbolicColor);
+ current_color->type = COLOR_TYPE_CURRENT_COLOR;
+ current_color->ref_count = 1;
+ }
+
+ return current_color;
+}
+
/**
* gtk_symbolic_color_ref:
* @color: a #GtkSymbolicColor
color->win32.id,
resolved_color);
+ break;
+ case COLOR_TYPE_CURRENT_COLOR:
+ return FALSE;
break;
default:
g_assert_not_reached ();
color->win32.theme_class, color->win32.id);
}
break;
+ case COLOR_TYPE_CURRENT_COLOR:
+ s = g_strdup ("currentColor");
+ break;
default:
g_assert_not_reached ();
}
gpointer data,
GdkRGBA *resolved_color);
+GtkSymbolicColor * _gtk_symbolic_color_get_current_color (void);
+
G_END_DECLS
#endif /* __GTK_SYMBOLIC_COLOR_PRIVATE_H__ */